package main.states;



import java.awt.Font;

import main.GamePanel;

import org.newdawn.slick.Color;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Input;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.TrueTypeFont;
import org.newdawn.slick.state.BasicGameState;
import org.newdawn.slick.state.StateBasedGame;

public class Menu extends BasicGameState{

	private Color titleColor;
	private TrueTypeFont titleFont;
	private TrueTypeFont defaultFont;
	private int currentchoice =0;
	private String[] options ={"Start","Help","Quit"};

	public Menu(int state) {
		// TODO Auto-generated constructor stub
	}

	@Override
	public void init(GameContainer gc, StateBasedGame sbg)
			throws SlickException {
		titleColor = new Color(128,0,0);
		titleFont = new TrueTypeFont(new Font("Gill Sanz",Font.PLAIN,35), false);
		defaultFont = new TrueTypeFont(new Font("Gill Sanz",Font.PLAIN,25),false);
		
	}

	@Override
	public void render(GameContainer gc, StateBasedGame sbg, Graphics g)
			throws SlickException {
		//draw bg
			g.setColor(Color.black);
			g.drawRect(0,0,gc.getWidth(), gc.getHeight());
				
			//draw title
			g.setColor(titleColor);
			g.setFont(titleFont);
			g.drawString("Projecto Caos", (gc.getWidth()/2)-87, 70);
				
			//draw options
			g.setFont(titleFont);
			for(int k = 0; k<options.length;k++){
				if(k==currentchoice ){
					g.setColor(Color.white);
					g.setFont(defaultFont);
					g.drawString(options[k], (gc.getWidth()/2)-40, 170+k*50);
				}else {
					g.setFont(defaultFont);
					g.setColor(Color.darkGray);
				g.drawString(options[k], (gc.getWidth()/2)-40, 170+k*50);
				}
			}
		
	}

	@Override
	public void update(GameContainer gc, StateBasedGame sbg, int g)
			throws SlickException {
		Input input = gc.getInput();
		if(input.isKeyPressed(Input.KEY_UP)) currentchoice--;
		if(currentchoice==-1) currentchoice = options.length-1;
		if(input.isKeyPressed(Input.KEY_DOWN)) currentchoice++;
		if(currentchoice==options.length) currentchoice = 0;
		if(input.isKeyPressed(Input.KEY_ENTER)){
			if(currentchoice ==0){
				sbg.enterState(GamePanel.play);
			}
		}
	}

	@Override
	public int getID() {
		// TODO Auto-generated method stub
		return 0;
	}

}
